class_name PlayerWalkState
extends GameplayState

@onready var player: Player = $"../../../"


func _on_enter() -> void:
	player.play_animation(&"walk")

	player.add_tag(GameplayTagLibrary.State_Ground_Stand)
	player.add_tag(GameplayTagLibrary.State_Ground_Move_Walk)


func _on_update(delta: float) -> void:
	var movement_input := player.input_handler.get_axis("move_left", "move_right")
	player.velocity.x = movement_input * player.get_attribute("walk_speed").current_value * delta
	
	if movement_input * player.face_direction < 0:
		player.flip()


func _on_exit() -> void:
	player.remove_tag(GameplayTagLibrary.State_Ground_Stand)
	player.remove_tag(GameplayTagLibrary.State_Ground_Move_Walk)
